package com.legendshop.openportal.sdk.model.request.v4;

import cn.hutool.core.util.StrUtil;
import com.legendshop.openportal.sdk.model.BaseRequest;
import com.legendshop.openportal.sdk.model.constants.ShopBindWeixinOpenPlatformBindType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotNull;

import java.beans.Transient;

import static com.legendshop.openportal.sdk.model.constants.ApiPathConstantsV4.BIND_WEIXIN_OPEN_PLATFORM_V4;

/**
 * @author jzh
 * @version 1.0.0
 * @title ShopBindWeixinOpenPlatformV4Request
 * @date 2025/6/24 17:36
 * @description：店铺绑定微信开放平台账号V4请求参数
 */
@Data
public class ShopBindWeixinOpenPlatformV4Request extends BaseRequest {

    @ApiModelProperty("店铺ID")
    @NotNull(message = "店铺ID不能为空")
    private Long shopId;

    @NotNull(message = "绑定类型不能为空")
    @ApiModelProperty(value = "绑定类型 1、主动创建，2、绑定外部开放平台账号，3、录入外部开放平台账号，4、获取小程序已绑定开放平台账号")
    private ShopBindWeixinOpenPlatformBindType bindType;

    @ApiModelProperty(value = "指定的开放平台id")
    private String openAppid;

    @Override
    public String getApiPath() {
        return BIND_WEIXIN_OPEN_PLATFORM_V4;
    }

    @Transient
    @AssertTrue(message = "开放平台id不能为空")
    public Boolean getCheckOpenAppid() {
        if (ShopBindWeixinOpenPlatformBindType.BIND_OPEN_PLATFORM.equals(bindType) || ShopBindWeixinOpenPlatformBindType.INPUT_OPEN_PLATFORM.equals(bindType)) {
            return StrUtil.isNotBlank(openAppid);
        }
        return true;
    }
}
